package com.nero.controller;

import com.nero.common.pojo.EUTreeNode;
import com.nero.common.pojo.TaotaoResult;
import com.nero.service.IContentService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Nero on 18/8/7.
 */
@Controller
@RequestMapping("/content")
public class ContentController {
    @Resource
    IContentService contentServiceImpl;

    private static Logger logger = LogManager.getLogger(ContentController.class);

    @RequestMapping("/category/list")
    @ResponseBody
    public List<EUTreeNode> categoryList(@RequestParam(defaultValue = "0") long id) {
        logger.info("开始查找节点");
        List<EUTreeNode> list = contentServiceImpl.findTreeNodes(id);
        logger.info("查找节点结束");
        return list;
    }

    @RequestMapping("/category/create")
    @ResponseBody
    public TaotaoResult createCategory(@RequestParam String name, @RequestParam long parentId){
        contentServiceImpl.createCategory(name, parentId);

        return null;
    }
}
